import 'package:base_plugin/base_plugin.dart';
import 'package:finance_app/generated/l10n.dart';
import 'package:finance_app/src/common/app_colors.dart';
import 'package:finance_app/src/entities/coa_entity.dart';
import 'package:finance_app/src/widgets/form/form_edit_status_inherited_widget.dart';
import 'package:flutter/material.dart';

class JournalAccountItem extends StatelessWidget {
  final String amount;
  final CoaCoaAccountHeaderCoaAccountDetail account;
  final bool showHeader;
  final String title;

  const JournalAccountItem({
    Key key,
    this.showHeader = false,
    this.amount,
    this.account,
    this.title,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      decoration: BoxDecoration(
          color: Colors.white,
          border: Border(
              bottom: BorderSide(
            color: aceGrayColor,
            width: getDp(0.5),
          ))),
      padding: EdgeInsets.symmetric(horizontal: getDp(35), vertical: getDp(10)),
      child: Row(
        children: [
          Expanded(
            flex: 8,
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                if (showHeader)
                  Padding(
                    padding: EdgeInsets.only(
                      bottom: getDp(10),
                    ),
                    child: Text(
                      '$title',
                      style: TextStyle(
                        color: aceDarkGrayColor,
                        fontSize: getSp(14),
                        fontWeight: FontWeight.w400,
                        height: 1,
                      ),
                    ),
                  ),
                Text(
                  '${account.name}',
                  style: FormEditStatusInheritedWidget.ofStyle(context),
                )
              ],
            ),
          ),
          Expanded(
            flex: 3,
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.end,
              children: [
                if (showHeader)
                  Padding(
                    padding: EdgeInsets.only(
                      bottom: getDp(10),
                    ),
                    child: Text(
                      S.current.amount,
                      style: TextStyle(
                        color: aceDarkGrayColor,
                        fontSize: getSp(14),
                        fontWeight: FontWeight.w400,
                        height: 1,
                      ),
                    ),
                  ),
                Text(
                  '$amount',
                  style: FormEditStatusInheritedWidget.ofStyle(context),
                )
              ],
            ),
          ),
        ],
      ),
    );
  }
}
